package bookoperations;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-05-25
 * Time: 16:05
 */
public class ReturnOperation implements IBookOperations{
    @Override
    public void work(BookList booklist) {
        System.out.println("请输入您要归还的图书书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int size = booklist.getUseSize();
        for (int i = 0; i < size; i++) {
            if(booklist.getBook(i).getName().equals(name)&&(booklist.getBook(i).isState())){
                booklist.getBook(i).setState(false);
                System.out.println("归还图书成功！！！");
                return;
            }
        }
        System.out.println("不存在这本书,归还图书失败！！！");
    }
}
